﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataDqOrder" @search="getTableDataDqOrder">
      <el-row>
        
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="scheduleNumber_FormItem" prop="scheduleNumber" label="主排程号">
            <el-input v-model="searchDataDqOrder.scheduleNumber" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="orderCode_FormItem" prop="orderCode" label="工单编码">
            <el-input v-model="searchDataDqOrder.orderCode" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="orderStatus_FormItem" prop="orderStatus" label="工单状态">
            <el-input v-model="searchDataDqOrder.orderStatus" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="orderStateCode_FormItem" prop="orderStateCode" label="工单状态编码">
            <el-input v-model="searchDataDqOrder.orderStateCode" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="scheduleCode_FormItem" prop="scheduleCode" label="排程编码">
            <el-input v-model="searchDataDqOrder.scheduleCode" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="scheduleStatus_FormItem" prop="scheduleStatus" label="排程状态">
            <el-input v-model="searchDataDqOrder.scheduleStatus" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="scheduleStateCode_FormItem" prop="scheduleStateCode" label="排程状态编码">
            <el-input v-model="searchDataDqOrder.scheduleStateCode" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="productCode_FormItem" prop="productCode" label="产品编码">
            <el-input v-model="searchDataDqOrder.productCode" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="productName_FormItem" prop="productName" label="产品名称">
            <el-input v-model="searchDataDqOrder.productName" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="materialCode_FormItem" prop="materialCode" label="物料编码">
            <el-input v-model="searchDataDqOrder.materialCode" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="routeCode_FormItem" prop="routeCode" label="工艺编号">
            <el-input v-model="searchDataDqOrder.routeCode" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="routeName_FormItem" prop="routeName" label="工艺名称">
            <el-input v-model="searchDataDqOrder.routeName" clearable></el-input>
        </el-form-item>
    </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/DqOrder/Add'" icon='fa fa-plus' type='primary' :button-text="$t('message._system.common.vm.add')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/DqOrder/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message._system.common.vm.batchdelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/DqOrder/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message._system.common.vm.import')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/DqOrder/DqOrderExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message._system.common.vm.export')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefDqOrder" v-bind="tableDataDqOrder">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
          <el-button text type="primary" @click="OnEditrowClick(scope.row)" v-auth="'/api/DqOrder/Edit'">{{ $t('message._system.common.vm.edit') }}</el-button>
					<el-button text type="primary" @click="OnDetailsrowClick(scope.row)" v-auth="'/api/DqOrder/{id}'">{{ $t('message._system.common.vm.detail') }}</el-button>
					<el-popconfirm :title="$t('message._system.common.vm.deletetip')"  @confirm="onDelete(scope.row)">
						<template #reference>
							<el-button text type="danger" v-auth="'/api/DqOrder/BatchDelete'">{{ $t('message._system.common.vm.delete') }}</el-button>
						</template>
					</el-popconfirm>
        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="泰国电驱工单管理;true;TyMES.Controllers;DqOrder">
import {  ElMessageBox, ElMessage } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { DqOrderApi } from '/@/api/baseinformation/DqOrder';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateDqOrder = reactive({
    
});

const searchDataDqOrder = ref({
    			scheduleNumber: null,
			orderCode: null,
			orderStatus: null,
			orderStateCode: null,
			scheduleCode: null,
			scheduleStatus: null,
			scheduleStateCode: null,
			productCode: null,
			productName: null,
			materialCode: null,
			routeCode: null,
			routeName: null,

});

// 定义变量内容
const tableRefDqOrder = ref();
const tableDataDqOrder = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
  
        {title:'工厂编号',key: 'factoryCode',type: 'text',isCheck: true},
        {title:'产线编号',key: 'lineCode',type: 'text',isCheck: true},
        {title:'产线名称',key: 'lineName',type: 'text',isCheck: true},
        {title:'主排程号',key: 'scheduleNumber',type: 'text',isCheck: true},
        {title:'计划开始时间',key: 'startTime',type: 'text',isCheck: true},
        {title:'计划结束时间',key: 'endTime',type: 'text',isCheck: true},
        {title:'工单编码',key: 'orderCode',type: 'text',isCheck: true},
        {title:'工单数量',key: 'orderQty',type: 'text',isCheck: true},
        {title:'工单类型',key: 'orderType',type: 'text',isCheck: true},
        {title:'工单状态',key: 'orderStatus',type: 'text',isCheck: true},
        {title:'工单状态编码',key: 'orderStateCode',type: 'text',isCheck: true},
        {title:'工单开始时间',key: 'orderStartTime',type: 'text',isCheck: true},
        {title:'工单结束时间时间',key: 'orderEndTime',type: 'text',isCheck: true},
        {title:'排程编码',key: 'scheduleCode',type: 'text',isCheck: true},
        {title:'排程数量',key: 'scheduleQty',type: 'text',isCheck: true},
        {title:'排程状态',key: 'scheduleStatus',type: 'text',isCheck: true},
        {title:'排程状态编码',key: 'scheduleStateCode',type: 'text',isCheck: true},
        {title:'排程开始时间',key: 'scheduleStartTime',type: 'text',isCheck: true},
        {title:'排程结束时间',key: 'scheduleEndTime',type: 'text',isCheck: true},
        {title:'产品编码',key: 'productCode',type: 'text',isCheck: true},
        {title:'产品名称',key: 'productName',type: 'text',isCheck: true},
        {title:'产品版本',key: 'productVersion',type: 'text',isCheck: true},
        {title:'物料编码',key: 'materialCode',type: 'text',isCheck: true},
        {title:'物料名称',key: 'materialName',type: 'text',isCheck: true},
        {title:'物料版本',key: 'materialVersion',type: 'text',isCheck: true},
        {title:'工艺编号',key: 'routeCode',type: 'text',isCheck: true},
        {title:'工艺名称',key: 'routeName',type: 'text',isCheck: true},
        {title:'工艺路线版本',key: 'routeVersion',type: 'text',isCheck: true},
        {title:'priority',key: 'priority',type: 'text',isCheck: true},
	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataDqOrder = () => {
    tableRefDqOrder.value.doSearch(DqOrderApi().search, searchDataDqOrder.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message._system.common.vm.add'), CreateDialog, null, getTableDataDqOrder)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message._system.common.vm.edit'), EditDialog, row, getTableDataDqOrder)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message._system.common.vm.detail'), DetailsDialog, row, getTableDataDqOrder)
};

// 删除
const onDelete = (row: any) => {
    DqOrderApi().delete([row.ID]).then(() => { getTableDataDqOrder()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefDqOrder.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      DqOrderApi().delete(selectedids).then(() => { getTableDataDqOrder()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message._system.common.vm.import'), ImportDialog, null, getTableDataDqOrder)
};

const onExport = () => {
	const selected = tableRefDqOrder.value.getSelectedRows();
	if (selected.length > 0) {
		DqOrderApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		DqOrderApi().export({});
	}
};

// 页面加载时
onMounted(() => {
     
        getTableDataDqOrder();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

